﻿using DevExpress.Mvvm.Gantt;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace DevWpfApp.XmlStore
{
    [DataContract]
    public class GanttResourceCollectionProxy
    {
        public GanttResourceCollectionProxy()
        {
            ResourceProxies = new ObservableCollection<GanttResourceProxy>();
        }
        [DataMember]
        public ObservableCollection<GanttResourceProxy> ResourceProxies { get; set; }

        public ObservableCollection<GanttResource> Resources
        {
            set
            {
                ResourceProxies.Clear();
                foreach (var resource in value)
                {
                    ResourceProxies.Add(new GanttResourceProxy { GanttResource = resource });
                }
            }
            get
            {
                ObservableCollection<GanttResource> tasks = new ObservableCollection<GanttResource>();

                foreach (var task in ResourceProxies)
                {
                    tasks.Add(task.GanttResource);
                }
                return tasks;
            }
        }
    }
}
